using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using DS.SludgeEngine.Base;
using DS.SludgeEngine.Base.GlobalContent;

namespace DS.SludgeEngine.Input
{
    public class InputController : IInputControllerService, IGameComponent
    {
        private Dictionary<Actions, Keys> keyMappings = new Dictionary<Actions, Keys>();

        public Dictionary<Actions, Keys> KeyMappings
        {
            get { return keyMappings; }
            set { keyMappings = value; }
        }

        public InputController(InputConfiguration config)
        {
            foreach (InputItem input in config.Items)
            {
                keyMappings.Add(input.Action, input.Key);
            }
        }

        public bool IsKeyDown(Actions action)
        {
            KeyboardState keystate = Keyboard.GetState();
            return keystate.IsKeyDown(keyMappings[action]);
        }

        #region IGameComponent Members

        public void Initialize()
        {
            
        }

        #endregion
    }
}
